package com.qwe.graduation.config;

import com.sun.istack.internal.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lzf
 * @date 2022/10/21 9:01
 * @description ResourcesConfig
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(@NotNull ResourceHandlerRegistry registry) {
        String os = System.getProperty("os.name");
        //如果是Windows系统
        if (os.toLowerCase().startsWith("win")) {
            registry.addResourceHandler("/ecmweb/pic/**").addResourceLocations("file:D:/test/img/");
        }else{
            //linux 和mac
            registry.addResourceHandler("/ecmweb/pic/**").addResourceLocations("file:/opt/file/image/");
        }
    }
}